package com.cv.platform.controller.platform.video;

import com.cv.framework.common.pojo.Result;
import com.cv.platform.service.video.CvVideoDislikeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;

/**
 * 视频平台 - 视频踩控制层
 *
 * @author Charles_XDXD
 */
@Tag(name = "视频平台 - 视频踩控制层")
@RestController
@RequestMapping("/platform/video/dislike")
public class CvVideoDislikeController {

    @Resource
    private CvVideoDislikeService cvVideoDislikeService;

    @GetMapping("getDislikeCount")
    @Operation(summary = "获取视频踩数")
    @PermitAll
    public Result<Integer> getDislikeCount(Long videoId) {
        return Result.success(cvVideoDislikeService.getVideoDislikeCount(videoId));
    }

    @GetMapping("getDislikeStatus")
    @Operation(summary = "获取视频踩状态")
    public Result<Boolean> getDislikeStatus(Long videoId) {
        return Result.success(cvVideoDislikeService.getVideoDislikeStatus(videoId));
    }

    @PostMapping("saveDislike")
    @Operation(summary = "保存视频踩记录")
    public Result<Boolean> saveDislike(Long videoId) {
        cvVideoDislikeService.saveVideoDislike(videoId);
        return Result.success(true);
    }

    @DeleteMapping("cancelDislike")
    @Operation(summary = "取消视频踩记录")
    public Result<Boolean> cancelDislike(Long videoId) {
        cvVideoDislikeService.cancelVideoDislike(videoId);
        return Result.success(true);
    }

}
